Clean up a bunch of clang warnings while on the plane.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 10 Sep 2012 04:57:25 +0000 (04:57 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 10 Sep 2012 04:57:25 +0000 (04:57 +0000)
19 files changed:
gpsbabel/alan.c
gpsbabel/garmin_gpi.h
gpsbabel/garmin_tables.c
gpsbabel/garmin_tables.h
gpsbabel/garmin_txt.c
gpsbabel/itracku.c
gpsbabel/jeeps/gpsdatum.h
gpsbabel/jeeps/gpslibusb.c
gpsbabel/jeeps/gpsmath.c
gpsbabel/jeeps/gpsmath.h
gpsbabel/jeeps/gpsusbcommon.c
gpsbabel/jeeps/gpsutil.c
gpsbabel/jeeps/gpsutil.h
gpsbabel/lmx.c
gpsbabel/mapopolis.c
gpsbabel/mmo.c
gpsbabel/naviguide.c
gpsbabel/skytraq.c
gpsbabel/xcsv_tokens.in

index 0eea38e6dc95c002e5659b66ddc3c50229e7a3ef..d855fd66e41cfe886ff84bbe09fe0305904b7bde 100644 (file)
@@ -421,7 +421,8 @@ static void trl_swap(struct trldata* trldata)
 
 /**************************************************************************/
 
-static void str2lab(char* dest, char* src, int len, char* fmt, int n)
+static void str2lab(char* dest, const char* src, int len, const char* fmt,
+                   int n)
 {
   int i,j;
 
index 9e816ba113db9d4ccb17701cd0b3970530a514ac..4e2b11f0b0355312f5ded674fb0818dce7466849 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef GARMIN_GPI_H
 #define GARMIN_GPI_H
 
-static char gpi_bitmap[] = {
+static unsigned char gpi_bitmap[] = {
   0x00,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x08,0x00,0x00,0x00,0x40,0x02,0x00,0x00,
   0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0xff,0x00,0xff,0x00,0x01,0x00,0x00,0x00,
   0x6c,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
index 161f15c56374ece94eb7bb411b73fd0503829e6b..287224cffc044b5fa9079ef855f9427e60a6eb54 100644 (file)
@@ -729,7 +729,7 @@ gt_switch_display_mode_value(const unsigned char display_mode, const int protoid
   }
 }
 
-char*
+const char*
 gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, int* dynamic)
 {
   icon_mapping_t* i;
@@ -993,7 +993,7 @@ gt_get_mps_grid_longname(const grid_type grid, const char* module)
 const char*
 gt_get_mps_datum_name(const int datum_index)
 {
-  char* result;
+  const char* result;
   datum_mapping_t* d;
 
   result = GPS_Math_Get_Datum_Name(datum_index);
index 8a010904e5f86aeaf45079e0133ad02b2bc46780..b31de0fc23ba0925094cfd248b6e4ef8b7b701e8 100644 (file)
@@ -36,7 +36,7 @@ typedef struct icon_mapping {
 
 typedef enum {MAPSOURCE, PCX, GARMIN_SERIAL, GDB} garmin_formats_e;
 
-char* gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, int* dynamic);
+const char* gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, int* dynamic);
 int gt_find_icon_number_from_desc(const char* desc, garmin_formats_e garmin_format);
 
 extern icon_mapping_t garmin_icon_table[];
index a6e288f9b957bad36122a2d2a1b59d067a04da1d..3be03bf24edf590b6324727546daa9fd2b11b3ee 100644 (file)
@@ -139,7 +139,7 @@ static info_t* route_info;
 static int route_idx;
 static info_t* cur_info;
 
-static char* headers[] = {
+static const char* headers[] = {
   "Name\tDescription\tType\tPosition\tAltitude\tDepth\tProximity\tTemperature\t"
   "Display Mode\tColor\tSymbol\tFacility\tCity\tState\tCountry\t"
   "Date Modified\tLink\tCategories",
@@ -531,11 +531,11 @@ write_waypt(const waypoint* wpt)
   unsigned char wpt_class;
   garmin_fs_p gmsd;
   char* wpt_type;
-  char* dspl_mode;
+  const char* dspl_mode;
   const char* country;
   double x;
   int i, icon, dynamic;
-  char* icon_descr;
+  const char* icon_descr;
 
   gmsd = GMSD_FIND(wpt);
 
@@ -602,7 +602,8 @@ write_waypt(const waypoint* wpt)
   icon_descr = gt_find_desc_from_icon_number(icon, GDB, &dynamic);
   print_string("%s\t", icon_descr);
   if (dynamic) {
-    xfree(icon_descr);
+    // sleaze alert: cast away constness.
+    xfree((char *) icon_descr);
   }
 
   print_string("%s\t", GMSD_GET(facility, ""));
index be26c2e7ac584924c1c8898dfe81e4cbeafb567b..8efd03c05e0167942c0be30fcdf7231a243e7189 100644 (file)
@@ -57,7 +57,7 @@ static void itracku_file_read_waypts(gbfile* fin, void (*waypt_add)(waypoint* wp
 static void itracku_file_write_waypt(gbfile* fout, const waypoint* wpt);
 
 /* itracku device access */
-static const char read_update_data_command[] = { 0x60, 0xb5, 0, 0, 0, 0, 0 }; /* command string to start memory dump */
+static const unsigned char read_update_data_command[] = { 0x60, 0xb5, 0, 0, 0, 0, 0 }; /* command string to start memory dump */
 static const int timeout = 1000; /* timeout for all read operations */
 static const char update_end_marker[] = "WP Update Over"; /* end marker for the memory dump */
 static const int update_end_marker_size = sizeof(update_end_marker);
index faa54fe8623a854ab332ea94d36ec7124adee470..ff74750261fc9c83b3443da32af24c3c0227cee5 100644 (file)
@@ -9,7 +9,7 @@ extern "C"
 
 
   typedef struct GPS_SEllipse {
-    char*   name;
+    const char*   name;
     double a;
     double invf;
   } GPS_OEllipse, *GPS_PEllipse;
@@ -48,7 +48,7 @@ extern "C"
 
 
   typedef struct GPS_SDatum {
-    char*   name;
+    const char*   name;
     int    ellipse;
     double dx;
     double dy;
@@ -187,7 +187,7 @@ extern "C"
 
 
   typedef struct GPS_SDatum_Alias {
-    char* alias;
+    const char* alias;
     const int datum;
   } GPS_ODatum_Alias, *GPS_PDatum_Alias;
 
@@ -227,7 +227,7 @@ extern "C"
 
 
   /* UK Ordnance Survey Nation Grid Map Codes */
-  static char* UKNG[]= {
+  static const char* UKNG[]= {
     "SV","SW","SX","SY","SZ","TV","TW","SQ","SR","SS","ST","SU","TQ","TR",
     "SL","SM","SN","SO","SP","TL","TM","SF","SG","SH","SJ","SK","TF","TG",
     "SA","SB","SC","SD","SE","TA","TB","NV","NW","NX","NY","NZ","OV","OW",
index acb732c784124e2064d65d289582f33ee72614ce..5122ff11cf0b350ead9e57bb8f891913c71d048e 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #endif
 #if HAVE_LIBUSB
-#include <usb.h>
+#include "usb.h"
 #include "gps.h"
 #include "garminusb.h"
 #include "gpsusbcommon.h"
@@ -204,9 +204,9 @@ gusb_atexit_teardown(void)
 unsigned
 gusb_reset_toggles(void)
 {
-  static const char  oinit[12] =
+  static const unsigned char  oinit[12] =
   {0, 0, 0, 0, GUSB_SESSION_START, 0, 0, 0, 0, 0, 0, 0};
-  static const char  oid[12] =
+  static const unsigned char  oid[12] =
   {20, 0, 0, 0, 0xfe, 0, 0, 0, 0, 0, 0, 0};
   garmin_usb_packet iresp;
   int t;
index 1a025012db98c0eda7c8d21791a5b2e1852f59db..a5e9de25d869c234c86b1e0b9fb920a5763ad8ba 100644 (file)
@@ -2572,7 +2572,7 @@ int32 GPS_Lookup_Datum_Index(const char* n)
   return -1;
 }
 
-char*
+const char*
 GPS_Math_Get_Datum_Name(const int datum_index)
 {
   return GPS_Datum[datum_index].name;
index c1ac21145e07b091c7efd11f1a32f30b317d93e4..839fece39a793ab57b6c52a0004e221651a931f7 100644 (file)
@@ -141,7 +141,7 @@ extern "C"
                                  const double lambda0, const double E0, const double N0);
 
   int32 GPS_Lookup_Datum_Index(const char* n);
-  char* GPS_Math_Get_Datum_Name(const int datum_index);
+  const char* GPS_Math_Get_Datum_Name(const int datum_index);
 
 #endif
 
index fb3ae7306026dc95f5eb7d2d5df7f60359ec5d2f..79e5b204562118935400d3452c394e475d1f044a 100644 (file)
@@ -212,7 +212,7 @@ gusb_list_units()
 void
 gusb_id_unit(garmin_unit_info_t* gu)
 {
-  static const char  oid[12] =
+  static const unsigned char  oid[12] =
   {20, 0, 0, 0, 0xfe, 0, 0, 0, 0, 0, 0, 0};
   garmin_usb_packet iresp;
   int i;
index 8a6201b7e86da2058eb21798b63f8871dedd0b02..a9374c68ad9bd90b487c428ad9890bb7e9df597b 100644 (file)
@@ -457,7 +457,7 @@ int32 GPS_Util_Block(int32 fd, int32 state)
 ** @@
 ****************************************************************************/
 
-void GPS_Warning(char* s)
+void GPS_Warning(const char* s)
 {
   if (!gps_warning) {
     return;
@@ -481,7 +481,7 @@ void GPS_Warning(char* s)
 ** @@
 ****************************************************************************/
 
-void GPS_Fatal(char* s)
+void GPS_Fatal(const char* s)
 {
 
   fprintf(stderr,"[FATAL] %s\n",s);
@@ -501,7 +501,7 @@ void GPS_Fatal(char* s)
 ** @@
 ****************************************************************************/
 
-void GPS_Error(char* fmt, ...)
+void GPS_Error(const char* fmt, ...)
 {
   va_list argp;
   va_start(argp, fmt);
index 625176659801cd81e899c95ead4115ecfa8843f0..3b8f25dac141164cb93369b30097e04adce4d0f0 100644 (file)
@@ -24,10 +24,10 @@ extern "C"
   void   GPS_Util_Put_Uint(UC* s, const uint32 v);
   uint32 GPS_Util_Get_Uint(const UC* s);
 
-  void   GPS_Warning(char* s);
-  void   GPS_Error(char* fmt, ...);
+  void   GPS_Warning(const char* s);
+  void   GPS_Error(const char* fmt, ...);
   void   GPS_Serial_Error(const char* hdr, ...);
-  void   GPS_Fatal(char* s);
+  void   GPS_Fatal(const char* s);
   void   GPS_Enable_Error(void);
   void   GPS_Enable_Warning(void);
   void   GPS_Disable_Error(void);
index 53d43eef757c08985ca88ee4b34f14af3977ebb0..66c71deb0f87c5f13e289168347ae948fe4eb953 100644 (file)
@@ -63,7 +63,7 @@ lmx_wr_deinit(void)
   gbfclose(ofd);
 }
 
-static char*
+static const char*
 lmx_stag(int tag)
 {
   switch (tag) {
index 4ff7c7d275584beb6ad0266ac3d46f69cf8380e3..7846a347e44bb03e1d1d9e8bc444866bd4968005 100644 (file)
@@ -93,7 +93,7 @@ wr_deinit(void)
   mkshort_del_handle(&mkshort_handle);
 }
 
-convert_rec0(struct record0* rec0)
+void convert_rec0(struct record0* rec0)
 {
   Lon1 = be_read32(&rec0->lon1) / LONDIV;
   Lat1 = be_read32(&rec0->lat1) / LATDIV;
index 979e3c24cedc785c9c9fa73850567c2af216bc35..bbe234944cf962ffd54fd7d378bec91edb73f07d 100644 (file)
@@ -186,7 +186,7 @@ mmo_readstr(void)
       len = (unsigned)gbfgetc(fin);
       if (len > 0) {
         int ii, jj, ch, resbytes=0;
-        res = xmalloc(len*2 + 1); // bigger to allow for utf-8 expansion
+        res = (char *) xmalloc(len*2 + 1); // bigger to allow for utf-8 expansion
         for (ii=0; ii<len; ii++) {
           char utf8buf[8];
           int utf8len;
@@ -207,7 +207,7 @@ mmo_readstr(void)
     // positive values of len are for strings longer than 254, handled below:
   }
   // length zero returns an empty string
-  res = xmalloc(len + 1);
+  res = (char *) xmalloc(len + 1);
   res[len] = '\0';
   if (len) {
     gbfread(res, len, 1, fin);
index 80be9bdb3715edcedd54f34b87f96118b885cbad..5bebab6640b7a23bda540ad8648a62631104a153 100644 (file)
 /* Naviguide file header */
 typedef struct {
   gbuint16 nof_wp;    /* Little endean format */
-  char pad1[6];      /* 0xff, 0xff, 0x01, 0x00, 0x06, 0x00 */
+  unsigned char pad1[6];      /* 0xff, 0xff, 0x01, 0x00, 0x06, 0x00 */
   char signature[9]; /* cWaypoint */
-  char pad2[4];      /* 0x01, 0x00, 0x00, 0x00 */
+  unsigned char pad2[4];      /* 0x01, 0x00, 0x00, 0x00 */
 } ng_file_header_t;
 
 /* Naviguide waypoint/rout data  */
 typedef struct {
-  char pad1[8];   /*  0xfe, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 */
+  unsigned char pad1[8];   /*  0xfe, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 */
   /* coordination are in old israeli grid */
   gbuint32 East;
   gbuint32 North;
-  char pad2[2];  /* 0x01, 0x01 */
+  unsigned char pad2[2];  /* 0x01, 0x01 */
   gbuint32 Alt;
   char CommentLength;
 } ng_wp_data_t;
 
 typedef struct {
-  char pad1[2]; /* 0x01, 0x80 */
+  unsigned char pad1[2]; /* 0x01, 0x80 */
   gbuint16 next_wp;
-  char pad2[2]; /* 0x00, 0x00 */
+  unsigned char pad2[2]; /* 0x00, 0x00 */
 } ng_next_wp_t;
 
 typedef struct {
index 99df9d16bd2e501e7417c8b6217a18032a0f63d3..3af0730f481ab0bfae4aab3b7110f9c407929e62 100644 (file)
@@ -740,9 +740,9 @@ process_data_sector(struct read_state *pst, const gbuint8 *buf, int len)
 
 /* Note: the buffer is being padded with 0xFFs if necessary so there are always SECTOR_SIZE valid bytes */
 static int
-skytraq_read_single_sector(int sector, gbuint8 *buf)
+skytraq_read_single_sector(unsigned int sector, gbuint8 *buf)
 {
-  gbuint8 MSG_LOG_SECTOR_READ_CONTROL[2] = { 0x1B, sector };
+  gbuint8 MSG_LOG_SECTOR_READ_CONTROL[2] = { 0x1B, (gbuint8)(sector) };
   int errors = 5;              /* allow this many errors */
   int c, i, j, cs;
   gbuint8 buffer[16];
index dc3fa4b3993ddde179423fc755b0d5d83ca624f9..5f3637d88eb187702c46e7435b8668c6a47a60a0 100644 (file)
@@ -1,4 +1,4 @@
-struct xt_mapping {char *name; int xt_token; };
+struct xt_mapping {const char *name; int xt_token; };
 %%
 ALT_FEET, XT_ALT_FEET
 ALT_METERS, XT_ALT_METERS